import threading

import time

import vserial


if __name__ == '__main__':
    print(__name__)


ser = vserial.serial.Serial("COM1", 115200,interCharTimeout=0.1)


def vsend_func(what):
    print(what)
    
    for i in range(10000):
        
        print(i)
        ser.write("1111asdfghjk".encode("UTF-8"))
        time.sleep(1)



def vrecv_func(what):
    while 1:
        readbuf=ser.read(100)
        if readbuf == 'ABC'.encode("UTF-8"):
            print("quit")
            return
        print(readbuf)


vthread_list= []



vsend = threading.Thread(target=vsend_func, args=('vsend', ))
vthread_list.append(vsend)
vrecv = threading.Thread(target=vrecv_func, args=('vrecv', ))
vthread_list.append(vrecv)


vsend.start()
vrecv.start()
vsend.join()
vrecv.join()




